LD_LIBRARY_PATH=
rm *.so
rm *.o
rm *.out

echo ">starts to generate first_shared.o"
	g++ -g -fPIC -c -Wall first_shared.cpp
	ls|grep first

echo ">starts to generate firstshared.so"
	g++ -g -shared -o libfirstshared.so first_shared.o
	ls|grep first

echo ">link to testbin, call function in  firstshared.so without set LD_LIBRARY_PATH"
	g++ -g -Wall -o testbin main.cpp libfirstshared.so
echo ""
	./testbin

echo ""
echo ">now set LD_LIBRARY_PATH to current dir"
	export LD_LIBRARY_PATH=.
	env|grep LD_LIBRARY_PATH
echo ">execute again:"
	./testbin
	

echo ""
echo ""
echo ">Now test build libreal_name.so lib with soname:libsoname_test.so"
	g++ -g -fPIC -c -Wall first_shared.cpp
	g++ -g -shared -Wl,-soname,libsoname_test.so -o libreal_name.so first_shared.o

echo ">check the soname"
	objdump -p libreal_name.so |grep SONAME
	
echo "> link to libreal_name.so, but testbinso needs's libsoname_test.so"
	g++ -g -Wall -o testbinso main.cpp libreal_name.so
	export LD_LIBRARY_PATH=.
	./testbinso
	
echo ""
echo ""
echo"> now make softlink of libsoname_test.so, then run again"
	#in windows mounted folder can not perform ln -s 
	#ln -s libreal_name.so libsoname_test.so
	echo ">>use cp to replace ln in windows mounted folder. execute bin"
	#use cp insted
	cp libreal_name.so libsoname_test.so
	./testbinso
	
	